//package com.zjjh;
//
//import org.springframework.cloud.gateway.handler.predicate.PredicateDefinition;
//import org.springframework.cloud.gateway.route.RouteDefinition;
//import org.springframework.cloud.gateway.support.NameUtils;
//import org.springframework.stereotype.Component;
//import org.springframework.util.StringUtils;
//import org.springframework.web.server.WebFilter;
//
//import java.net.URI;
//import java.net.URISyntaxException;
//import java.util.*;
//
//@Component
//public class DynamicRouteServiceImpl {
//
//    public List<RouteDefinition> quertAllRoutes() throws URISyntaxException {
//        List<RouteDefinition> routeDefinitions = new ArrayList<>();
//        RouteDefinition definition = new RouteDefinition();
//        definition.setId(UUID.randomUUID().toString());
//        definition.setUri(new URI("http://localhost:8080"));
//        Map<String, Object> data = new LinkedHashMap();
//        data.put("authorize", true);
//        definition.setMetadata(data);
//        List<PredicateDefinition> predicates = new ArrayList<>();
//        PredicateDefinition predicateDefinition = new PredicateDefinition();
//        String text = "Path=/pay/**";
//        Map<String, String> path = new LinkedHashMap();
//        int eqIdx = text.indexOf(61);
//        predicateDefinition.setName(text.substring(0, eqIdx));
//        String[] args = StringUtils.tokenizeToStringArray(text.substring(eqIdx + 1), ",");
//        for(int i = 0; i < args.length; ++i) {
//            path.put(NameUtils.generateName(i), args[i]);
//        }
//        predicateDefinition.setArgs(path);
//        predicates.add(predicateDefinition);
//        routeDefinitions.add(definition);
//        return routeDefinitions;
//    }
//}
